<template>
  <!-- 第一个页面 -->
    <div class="history">
      <div class="top" v-show="insShowhistory">
        <div class="top-t">
          <h3>历史记录</h3>
          <van-icon name="delete-o" @click="shan" />
        </div>
        <van-tag
          plain
          type="primary"
          text-color="#666"
          v-for="(item, index) in historyKeywordList"
          :key="index"
          @click="fn(item)"
          >{{ item }}</van-tag
        >
      </div>
      <div class="bottom">
        <div class="bottom-t">
          <h3>热门搜索</h3>
        </div>
        <van-tag
          plain
          :type="item.is_hot ? 'danger' : 'primary'"
          text-color="#666"
          v-for="(item, index) in hotKeywordList"
          :key="index"
          @click="fn1(item.keyword)"
          >{{ item.keyword }}</van-tag
        >
      </div>
    </div>
</template>

<script>
import { postclearhistoryData } from "@/request/api";
export default {
  props: ["hotKeywordList", "historyKeywordList"],
  data() {
    return {
      insShowhistory: true,
    };
  },
  methods: {
    fn(val) {
      this.$emit("fatherfn", val);
    },
    fn1(val) {
      this.$emit("fatherfn1", val);
    },
    shan() {
      postclearhistoryData().then((res) => {
        console.log(res);
        this.$toast.success('删除成功');
        setTimeout(() => {
          this.insShowhistory = false;
        }, 700);
      });
    },
  },
};
</script>
 
<style lang = "less" scoped>
.history {
   z-index: 10;
  padding-bottom: 40px;
  .top {
    padding: 0.1rem;
    padding-bottom: 0.2rem;
    margin-bottom: 0.2rem;
    background-color: #fff;
    .top-t {
      display: flex;
      justify-content: space-between;
      font-size: 0.18rem;
    }
    .van-tag {
      margin: 0.1rem 0.1rem 0 0;
    }
  }
  .bottom {
    padding: 0.1rem;
    padding-bottom: 0.2rem;
    margin-bottom: 0.2rem;
    background-color: #fff;
    .bottom-t {
      font-size: 0.18rem;
    }
    .van-tag--danger.van-tag--plain {
      color: #ee0a24 !important;
      border: 1px solid #ee0a24 !important;
    }
    .van-tag {
      margin: 0.1rem 0.1rem 0 0;
    }
  }
}
</style>